# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=libratbag
pkgver=0.17
pkgrel=1
pkgdesc='A DBus daemon to configure gaming mice'
arch=('loong64' 'x86_64')
url='https://github.com/libratbag/libratbag'
license=('MIT')
depends=('glib2' 'libevdev' 'libudev.so' 'libunistring' 'json-glib' 'python' 'python-evdev' 'python-gobject')
optdepends=('linux: Linux 5.2 is required for Logitech wireless devices')
makedepends=('meson' 'swig' 'git' 'python-sphinx' 'python-sphinx_rtd_theme' 'systemd')
checkdepends=('check' 'valgrind' 'python-gobject' 'python-lxml')
validpgpkeys=('3DCE51D60930EBA47858BA4146F633CBB0EB4BF2'  # Filipe Laíns (FFY00) <lains@riseup.net>
              '3C2C43D9447D5938EF4551EBE23B7E70B467F0BF'  # Peter Hutterer (Who-T) <office@who-t.net>
              '4F60BCD32573AB28D84FD0C4CCF75EB2BBF8F69C') # Yaroslav Chvanov <yaroslav.chvanov@gmail.com>
# 2F2670AC164DB36F (Benjamin Tissoires <benjamin.tissoires@gmail.com>) should also be trusted  -- ass. FFY00
source=("git+$url#tag=v$pkgver?signed")
sha512sums=('SKIP')
provides=('ratbagd' 'liblur')
conflicts=('ratbagd' 'liblur')

build() {
  mkdir -p $pkgname/build
  cd $pkgname/build

  arch-meson .. \
  	-Dsystemd-unit-dir=/usr/lib/systemd/system \
  	-Ddocumentation=true

  ninja
}

check() {
  cd $pkgname/build

  meson test --no-rebuild
}

package() {
  cd $pkgname/build

  DESTDIR="$pkgdir" ninja install

  # Install documentation
  install -dm 755 "$pkgdir"/usr/share/doc/$pkgname
  cp -r -a --no-preserve=ownership doc/html "$pkgdir"/usr/share/doc/$pkgname
  rm -rf "$pkgdir"/usr/share/doc/$pkgname/html/.doctrees

  # Install license
  install -Dm 644 ../COPYING "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
